package storage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;

public class Profile {
	
	public String profileName;
	//Company Info
	public String cnee 					="";
	public String street				="";
	public String city					="";
	public String state					="";
	public String zip					="";
	public String country				="";
	public String telephone				="";
	public String email					="";
	public String contact				="";
	public String type					="";
	//Topocean Info
	public HashMap<String,ArrayList<String>> originEmployeeMap;
	public HashMap<String,ArrayList<String>> destEmployeeMap;
	public String saleHandler			="";
	//Billing 
	public double chargePerContainer	=0.0;
	public int term						=0;
	public String daysAfter				="";
	public String billTo				="";
	public String companyType			="";
	public Hashtable<String,ArrayList<Rule>> ruleList		= new Hashtable<String,ArrayList<Rule>>();
	public boolean active				= false;
	public JButton editButton 			= new JButton("Edit Profile");
	public JCheckBox activeCheckBox		= new JCheckBox("Test Profile?");
	public JLabel profileNameLabel		= new JLabel();
	
	public Profile(String profileName, String cnee, String street, String city, String state, String zip,
			String country, String telephone,
			String email, String contact, String type, HashMap<String,ArrayList<String>> originEmployeeMap,
			HashMap<String,ArrayList<String>> destEmployeeMap, String saleHandler, double chargePerContainer,
			int term, String daysAfter, String billTo, String companyType){
		this.profileName = profileName;
		this.cnee = cnee;
		this.street = street;
		this.state = state;
		this.city = city;
		this.zip = zip;
		this.country = country;
		this.telephone = telephone;
		this.email = email;
		this.contact = contact;
		this.type = type;
		this.originEmployeeMap = originEmployeeMap;
		this.destEmployeeMap = destEmployeeMap;
		this.saleHandler = saleHandler;
		this.chargePerContainer = chargePerContainer;
		this.term = term;
		this.daysAfter = daysAfter;
		this.billTo = billTo;
		this.companyType = companyType;
	}
	public HashMap<String, ArrayList<String>> getEmployees(boolean origin){
		if(origin){
			return originEmployeeMap;
		}else{
			return destEmployeeMap;
		}
	}
	public Profile(){
		
	}
	@SuppressWarnings("unchecked")
	public Profile clone(){
		Profile p= new Profile(this.profileName, this.cnee, this.street, this.city,this.state, this.zip,
				this.country, this.telephone,
				this.email, this.contact, this.type, (HashMap<String,ArrayList<String>>)this.originEmployeeMap.clone(),
				(HashMap<String,ArrayList<String>>)this.destEmployeeMap.clone(), this.saleHandler, this.chargePerContainer,
				this.term, this.daysAfter, this.billTo, this.companyType);
		//clone each individual element
		Hashtable<String,ArrayList<Rule>> rlist = new Hashtable<String,ArrayList<Rule>>();
		Object[] keySet = this.ruleList.keySet().toArray();
		for(int i=0;i<keySet.length;i++){
			ArrayList<Rule> rules = ruleList.get(keySet[i]);
			ArrayList<Rule> newList = new ArrayList<Rule>();
			for(int z=0;z<rules.size();z++){
				newList.add(rules.get(z).clone());
			}
			rlist.put((String) keySet[i],newList);
		}
		p.ruleList = rlist;
		return p;
	}
}
